package cn.qyd;

import cn.qyd.common.Doctor;
import cn.qyd.common.Person;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.function.Consumer;

/**
 * @author 邱运铎
 * @date 2024-03-16 19:23
 */
public class LeiXingCaChuDemo {
    //下面这段代码因为类型擦除的问题会发生和下面的方法冲突，无法通过编译
//    public static  void myMethod(ArrayList<String> list) {
//        System.out.println("ArrayList<String> list");
//    }
    public static void myMethod(ArrayList<Integer> list) {
        System.out.println("ArrayList<Integer> list");
    }

    public static void main(String[] args) {
        ArrayList<Person> peoples = new ArrayList<>();
        peoples.add(new Doctor("qiu",2,"w"));
        ArrayList<? extends Person> persons = new ArrayList<>();
        ArrayList<? super Person> pers = new ArrayList<>();
        pers.add(new Doctor("q",2,"2"));
        persons = peoples;
        pers = peoples;
        System.out.println(((Person)pers.get(0)).getName());
        System.out.println(persons.get(0).getName());

        Consumer consumer = (s) -> System.out.println("nihoa" + s);
        consumer.accept("world!!!");


    }
}
